package com.baizhi.util;


import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPollUtil {
//
        private static int corePoolSize = Runtime.getRuntime().availableProcessors();

    public static int getCorePoolSize() {
        return corePoolSize;
    }

    public static void setCorePoolSize(int corePoolSize) {
        ThreadPollUtil.corePoolSize = corePoolSize;
    }

    //corePoolSize 用于指定核心线程数量
    //maximumPoolSize 指定最大线程数
    //keepAliveTime 和TimeUnit指定线程空闲后的最大存活时间
    public static ThreadPoolExecutor executor = new ThreadPoolExecutor(corePoolSize,
                    corePoolSize+1,
                    101,
                    TimeUnit.SECONDS,
                    new LinkedBlockingQueue<Runnable>(1000));

}
